// Shapes.h: interface for the CShape class.
//
//////////////////////////////////////////////////////////////////////
#pragma once

#ifndef _SHAPES_
#define _SHAPES_

#include <afxtempl.h>

typedef CArray<POINT, POINT> CPointArray;

class CShape : public CObject  
{
public:
	CShape(UINT uPenWidth=1, UINT uPenStyle = PS_SOLID, 
		   COLORREF colorPen=RGB(0, 0, 0), COLORREF colorBrush=RGB(255, 255, 255));
	virtual ~CShape();

	DECLARE_DYNAMIC(CShape)

protected:
	// properties
	UINT		m_uPenWidth;
	UINT		m_uPenStyle;
	COLORREF	m_colorPen;
	COLORREF	m_colorBrush;
	CPointArray	m_points;

public:
	// methods
	void Draw(CDC* pDC);
	void AddPoint(POINT pt) {m_points.Add(pt);}
	// overridable methods
	virtual BOOL IsFillable() {return TRUE;}
	virtual void Serialize(CArchive& ar);
	virtual void OnDrawContent(CDC* pDC) = 0;
	// for editting
	virtual BOOL StartEdit(CDC* pDC, POINT pt) = 0;
	virtual	BOOL OnLButtonDown(CDC* pDC, UINT nFlags, CPoint point) {return FALSE;}
	virtual	BOOL OnLButtonUp(CDC* pDC, UINT nFlags, CPoint point) {return FALSE;}
	virtual	BOOL OnLButtonDblClk(CDC* pDC, UINT nFlags, CPoint point) {return FALSE;}
	virtual	BOOL OnMouseMove(CDC* pDC, UINT nFlags, CPoint point) {return FALSE;}
};


class CLine : public CShape  
{
public:
	CLine(UINT uPenWidth=1, UINT uPenStyle = PS_SOLID, 
		   COLORREF colorPen=RGB(0, 0, 0));
	virtual ~CLine();
	DECLARE_SERIAL(CLine)
	// methods
	virtual void OnDrawContent(CDC* pDC);
	virtual BOOL IsFillable() {return FALSE;}
	virtual BOOL StartEdit(CDC* pDC, POINT pt);
	virtual	BOOL OnMouseMove(CDC* pDC, UINT nFlags, CPoint point);
};


class CRectangle : public CShape  
{
public:
	CRectangle(UINT uPenWidth=1, UINT uPenStyle = PS_SOLID, 
		   COLORREF colorPen=RGB(0, 0, 0), COLORREF colorBrush=RGB(255, 255, 255));
	virtual ~CRectangle();
	DECLARE_SERIAL(CRectangle)
	// methods
	virtual void OnDrawContent(CDC* pDC);
	virtual BOOL StartEdit(CDC* pDC, POINT pt);
	virtual	BOOL OnMouseMove(CDC* pDC, UINT nFlags, CPoint point);
};

#endif /* _SHAPES_ */